package com.joinway.framework.extension.net.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class NetUtils {

	private final static Logger log = LoggerFactory.getLogger(NetUtils.class);
	
	public static List<NameValuePair> buildNameValuePair(Map<String, String> params){
		List<NameValuePair> pair = null;
		
		if(params != null && params.size() > 0){
			pair = new ArrayList<>();
			
			Iterator<String> it = params.keySet().iterator();
			while(it.hasNext()){
				String name = String.valueOf(it.next());
				String value = String.valueOf(params.get(name));
				
				pair.add(buildNameValuePair(name, value));
			}
		}
		
		return pair;
	}
	
	public static NameValuePair buildNameValuePair(String name, String value){
		return new BasicNameValuePair(name, value);
	}
	
	private NetUtils(){}
}
